<?php
    define('DIR_TOCUT_PROJECT', '/home/www/workspaces/mklein/oncut/core/tocut');
    require_once('videoengine.php');

    class cutmerge extends videoEngine  {

        var $vconfig = array();


        function cutmerge(){
            //config einlesen
            $this->vconfig = parse_ini_file('video/vconfig.ini', true);
        }


        /*
         *
         */
        function sliceVideo($videoPath, $timelines = array(), $videoformat){
            //
            $optionArray = array();

            if($videoformat == "HD-Full"){

                $optionArray['vcodec']      = "mp4";
                $optionArray['level']       = 12;
                $optionArray['bitrate']     = $this->vconfig['bitrate']['hdfull'];
                $optionArray['size']        = $this->vconfig['backend']['xy_hdfull'];
                $optionArray['tragetdir']   = $this->vconfig['backend']['xy_hdfull_path'];

            }elseif($videoformat == "HD-Ready"){

                $optionArray['vcodec']      = "mp4";
                $optionArray['level']       = 12;
                $optionArray['bitrate']     = $this->vconfig['bitrate']['hdready'];
                $optionArray['size']        = $this->vconfig['backend']['xy_hdready'];
                $optionArray['tragetdir']   = $this->vconfig['backend']['xy_hdready_path'];

            }elseif(1 == 2){

            }

            //Schneidedaten holen
            $timelines = unserialize(file_get_contents(DIR_TOCUT_PROJECT."/1.txt"));
            //mock daten
                         /*array(
                            array(
                                'videoPath' => '/home/www/workspaces/mklein/oncut/core/video/frontend/hd_960_540/serenity.mp4',
                                'vStart'     => '00:00:05',
                                'vduration'  => '00:00:05'
                            )
                        );*/

            $i = 0;
            foreach ( $timelines as $slice) {
                $i ++;
                print_r($slice);
                //mock
                if($slice['vId'] == 1){
                    $vname = "klitschko.mp4";
                }elseif($slice['vId'] == 2){
                    $vname = "heissluftballon.mp4";
                }elseif($slice['vId'] == 3){
                    $vname = "kronkorken.mp4";
                }

                $this->exportVideo("/home/www/workspaces/mklein/oncut/core/video/frontend/hd_960_540/".$vname, $optionArray, $slice, $i);


            }

            $this->mergeVideo($i);

        }


    }

    $test = new cutmerge();
    $test->sliceVideo('', '', "HD-Ready");

?>
